<template>
  <div class="GEmployeeManageDetail">
    <zyInfoPanel title="人员详情" :showUnfoldButton="false" class="baseInfo">
      <div class="baseBox">
        <zy-modal-info :model-info="baseInfo" cell-num="2"></zy-modal-info>
      </div>
      <div class="cooperativeImgContent">
        <div class="imgItem card">
          <div class="itemTitle">身份证</div>
          <div class="itemContent">
            <el-upload
                class="upload-demo"
                drag
                action=""
                :httpRequest="uploadFile"
                :data="{type: 'legal_card_pros'}"
                accept=".jpg,.jpeg,.png,.bmp,.wbmp,.JPG,.JPEG,.PNG,.BMP,.WBMP"
                :show-file-list="false" disabled
            >
              <zy-image readonly v-model="card_img_cons" v-if="card_img_cons"></zy-image>
              <i class="el-icon-upload"></i>
              <div class="el-upload__text">
                请上传身份证正面
              </div>
            </el-upload>
            <el-upload
                class="upload-demo"
                drag
                action=""
                :httpRequest="uploadFile"
                :data="{type: 'legal_card_cons'}"
                accept=".jpg,.jpeg,.png,.bmp,.wbmp,.JPG,.JPEG,.PNG,.BMP,.WBMP"
                :show-file-list="false" disabled
            >
              <zy-image v-model="card_img_pros" readonly v-if="card_img_pros"></zy-image>
              <i class="el-icon-upload"></i>
              <div class="el-upload__text">
                请上传身份证反面
              </div>
            </el-upload>
          </div>
        </div>
      </div>
    </zyInfoPanel>
  </div>
</template>

<script>
	export default {
		name: "GEmployeeManageDetail",
		props: {},
		data() {
			return {
				baseInfo: [
					{
						title: '姓名',
						name: 'employee_name',
						type: 'input',
						value: '',
						readonly: true
					},
					{
						title: '联系方式',
						name: 'employee_mobile',
						type: 'input',
						value: '',
						readonly: true
					},
					{
						title: '职位',
						name: 'profession_desc',
						type: 'input',
						value: '',
						readonly: true
					},
					{
						title: '身份证号',
						name: 'card_no',
						type: 'input',
						value: '',
						readonly: true
					},
					{
						title: '所属企业',
						name: 'company_name',
						type: 'input',
						value: '',
						readonly: true
					},
					{
						title: '入职时间',
						name: 'ctime',
						type: 'input',
						value: '',
						readonly: true
					},
				],
				employee_id:'',
				card_img_cons:'',
				card_img_pros:''
      };
		},
		computed: {},
		watch: {},
		components: {},
		methods: {
			getData(){
				this.$axios.post(this.$api.admin_detailEmployee, {employee_id: this.employee_id}).then(res => {
					let {code, msg, data} = res;
					if (code === 200) {
						this.baseInfo = this.baseInfo.filter(item => {
							for (let key in data) {
								if (item.name === key) {
									item.value = data[item.name];
								}
							}
							return item
						});
						this.card_img_cons = data.card_img_cons;
						this.card_img_pros = data.card_img_pros;
					} else {
						this.$message.error(msg);
					}
				}).catch(ret => {
					this.$message.error(ret.msg || '服务繁忙，请稍后再试');
				})
      },
			uploadFile(params) {
				let index = params.data.index;
				this.$axios.post(this.$api.uploadFile, {
					isFile: true,
					file: params.file,
					operator: 'goods',
				}).then(res => {
					if (res.code == 200) {
						this.$message.success(res.msg);
						this.modelInfo[index].value = res.data.url;
					} else {
						this.$message.error(res.msg);
					}
				})
			},
    },
		mounted() {
			this.employee_id = this.$route.query.employee_id || '';
			this.getData();
		},
		created() {
		}
	}
</script>

<style scoped lang="less" src="@/style/government/personnelManage/employeeDetail/index.less">

</style>
